﻿#建议保存编码为：bom头 + utf8
param
(
	[parameter(Mandatory = $true)]
	[ValidateNotNullOrEmpty()]
	[String]$filename
)

if (Test-Path -LiteralPath "${PSScriptRoot}/_temp_")
{
	$private:f = Get-Item -Path "${PSScriptRoot}/_temp_"
	if ($private:f.createtime.AddSeconds(30) -lt (Get-Date) )
	{
		& "${PSScriptRoot}/Write-Error2.ps1"  '错误：存在临时文件。退出码2'
		exit 2
	}
	else
	{
		Remove-Item -Force "${PSScriptRoot}/_temp_"
	}
}

if (Test-Path -LiteralPath $filename)
{
	/usr/bin/mv $filename "${PSScriptRoot}/_temp_"
	/usr/bin/mv "${PSScriptRoot}/_temp_" $filename
}
else
{
	& "${PSScriptRoot}/Write-Error2.ps1"  '错误：找不到这个文件。退出码1 '
	exit 1
}

$private:fn = (Get-ChildItem -Path $filename).FullName
${private:fn}
& "${PSScriptRoot}/Write-Host2.ps1" "信息：文件刷新完毕"
exit 0
